package com.jinlia.show.modules.base.system.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jinlia.show.modules.base.system.entity.Label;
import com.jinlia.show.modules.base.system.entity.LabelRel;
import com.jinlia.show.modules.base.system.mapper.LabelRelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LabelRelMapperService  extends ServiceImpl<LabelRelMapper, LabelRel> {
    @Autowired
    private LabelMapperService labelMapperService;
    public LabelRel addLabelRel(LabelRel labelRel) {
        Label byId = labelMapperService.getById(labelRel.getLabelId());

        this.save(labelRel);
        return labelRel;
    }
    public LabelRel delLabelRel(LabelRel labelRel) {
        List<LabelRel> list = this.lambdaQuery().eq(LabelRel::getLabelId, labelRel.getLabelId())
                .eq(LabelRel::getEntityId, labelRel.getEntityId())
                .list();
        this.removeByIds( list);
        return labelRel;
    }
}
